//
// Created by FindBin on 2024/4/28.
//

#pragma once

#include "main.h"
#include "usart.h"


/**@defgroup use which rs485
 * @{
 */
#define USE_RS485_1
#define USE_RS485_2
/**
 * @}
 */



/**
 * @defgroup Configuration
 * @{
 */
#if defined(USE_RS485_1)

#define RS485_1_UART huart3
#define RS485_1_DE_port RS485_1_DE_GPIO_Port
#define RS485_1_DE_pin RS485_1_DE_Pin
#define RS485_BUFFER_SIZE_1 5           /// Receive data buffer size

#endif

#if defined(USE_RS485_2)

#define RS485_2_UART huart2
#define RS485_2_DE_port RS485_2_DE_GPIO_Port
#define RS485_2_DE_pin RS485_2_DE_Pin
#define RS485_BUFFER_SIZE_2 8       /// Receive data buffer size

#endif


/**
 * @}
 */
#if (defined(USE_RS485_1) | defined(USE_RS485_2))

/**
 * RS485 initialize
 */
void rs485_init();

/**
 * RS485 interpret callback
 */
void rs485_callback();

#endif

#if defined(USE_RS485_1)

/**
 * RS485 1 sends a message to the bus
 * @param pTxData Pointer to the transmit data
 * @param len data length
 */
void rs485_1_send_msg(uint8_t *pTxData, uint16_t len);

extern uint8_t rs485_rx_Buffer_1[RS485_BUFFER_SIZE_1];

#endif
#if defined(USE_RS485_2)

/**
 * RS485 2 sends a message to the bus
 * @param pTxData Pointer to the transmit data
 * @param len data length
 */
void rs485_2_send_msg(uint8_t *pTxData, uint16_t len);

extern uint8_t rs485_rx_Buffer_2[RS485_BUFFER_SIZE_2];

#endif




